import {getAPI} from "@/api/MyAxiosAPI";

const API = getAPI(false)

export async function getFriendsList(token: string) {
    const r = await API.get("/IM/friends/list", {
        headers: {
            "Authorization": token
        }
    })
    return r.data
}

/**
 * 获取待处理的好友请求
 */
export async function getFriendsRequestAPI(token: string) {
    const r = await API({
        url: "/IM/friends/list/ops",
        method: "GET",
        headers: {
            "Authorization": token
        }
    })
    return r.data
}

export async function addFriendsAPI(token: string, email: string) {
    const r = await API({
        url: "/IM/friends/add/email/" + email,
        method: "POST",
        headers: {
            Authorization: token
        }
    })
    return r.data
}

export async function agreeFriendsRequestAPI(token: string, friendsUid: string) {
    const r = await API({
        url: "IM/friends/agree/" + friendsUid,
        method: "POST",
        headers: {
            Authorization: token
        }
    })
    return r.data
}

export async function rejectFriendsRequestAPI(token: string, friendsUid: string) {
    const r = await API({
        url: "IM/friends/rejection/" + friendsUid,
        method: "POST",
        headers: {
            Authorization: token
        }
    })
    return r.data
}